﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Data.SqlClient;
using System.Text.RegularExpressions;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for UnitView.xaml
    /// </summary>
    public partial class UnitView : Page
    {
        public UnitView()
        {
            InitializeComponent();
        }

        private void addUnitBtn_Click_1(object sender, RoutedEventArgs e)
        {
            UnitAdd unitAddWindow = new UnitAdd();
            unitAddWindow.Content = null;
            mainContent.Children.Add(unitAddWindow.mainContent);
        }

        private void updateUnitBtn_Click_1(object sender, RoutedEventArgs e)
        {
            UnitUpdate unitUpdateWindow = new UnitUpdate();
            unitUpdateWindow.Content = null;
            mainContent.Children.Add(unitUpdateWindow.mainContent);
        }

        private void deleteunitBtn_Click_1(object sender, RoutedEventArgs e)
        {
            UnitDelete unitDeleteWindow = new UnitDelete();
            unitDeleteWindow.Content=null;
            mainContent.Children.Add(unitDeleteWindow.mainContent);
        }

        private void searchUnitBtn_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void unitView_Update_Click_1(object sender, RoutedEventArgs e)
        {
            UnitUpdate unitUpdateWindow = new UnitUpdate();
            unitUpdateWindow.Content = null;
            mainContent.Children.Add(unitUpdateWindow.mainContent);
            
            DataRowView drv = (DataRowView)displayUnitDetailsLstvw.SelectedItem;
            string x = drv.Row["unitID"].ToString();
            unitUpdateWindow.unitIDUpdateCmbx.Text = x;

        }

        private void unitView_Delete_Click_1(object sender, RoutedEventArgs e)
        {
            UnitDelete unitDeleteWindow = new UnitDelete();
            unitDeleteWindow.Content = null;
            mainContent.Children.Add(unitDeleteWindow.mainContent);

            DataRowView drv = (DataRowView)displayUnitDetailsLstvw.SelectedItem;
            string x = drv.Row["unitID"].ToString();
            unitDeleteWindow.unitIDDeleteCmbx.Text = x;

            MessageBox.Show(x);
        }

        private void unitView_Cancel_Click_1(object sender, RoutedEventArgs e)
        {
            displayUnitDetailsLstvw.SelectedItem = null;
        }

        private void mainContent_Loaded_1(object sender, RoutedEventArgs e)
        {
            Database.populateUnitListview(this);
        }
    }
}
